Skip to content

Support Export of LTX-Video 0.9.1#1652

Open
Yash-Vijay29 wants to merge 25 commits into
huggingface:mainfrom
Yash-Vijay29:timestep_cond
Open

Support Export of LTX-Video 0.9.1#1652
Yash-Vijay29 wants to merge 25 commits into
huggingface:mainfrom
Yash-Vijay29:timestep_cond

Conversation

@Yash-Vijay29

@Yash-Vijay29 Yash-Vijay29 commented Mar 27, 2026

Copy link
Copy Markdown

What does this PR do?

Adds support for to successfully convert LTX-Video 0.9.1 (a timestep_conditioning enabled version of LTX Video)
to be exported to IR graph. previously timestep_conditioning was not supported in exports and caused dummy timestep_conditioning to produce tensor a mismatch.

Created tiny-random-ltx-video-0.9.1 for github CI and testing.

Added inference and conversion tests.

TESTED HF VS OPTIMUM ACCURACY:

first ran :

wwb --base-model Lightricks/LTX-Video-0.9.1 --gt-data video_gen_test_ts/gt.csv --model-type text-to-video --hf --decode-timestep 0.05 --decode-noise-scale 0.025 --num-samples 10

then

wwb --target-model ltx-video-0.9.1-ov --gt-data video_gen_test_ts/gt.csv --model-type text-to-video --output ltx_video_genai_ts --decode-timestep 0.05 --decode-noise-scale 0.025 --num-samples 10

Accuracy: 0.9844858
Metrics_per_question:
metrics.csv

Before submitting

  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@Yash-Vijay29 Yash-Vijay29 changed the title Support timestep_conditioning for LTX-Video 0.9.1 Support Export of LTX-Video 0.9.1 Mar 27, 2026

@likholat likholat left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for tiny-random-ltx-0.9.1-video model conversion and inference.
You can refer to similar tests that already exist for the supported LTX model:

repo:huggingface/optimum-intel ltx-video path:/^tests\/openvino\//

@Yash-Vijay29 Yash-Vijay29 marked this pull request as draft April 25, 2026 07:27
@Yash-Vijay29 Yash-Vijay29 marked this pull request as ready for review April 25, 2026 17:36
@Yash-Vijay29

Copy link
Copy Markdown
Author

Please add tests for tiny-random-ltx-0.9.1-video model conversion and inference. You can refer to similar tests that already exist for the supported LTX model:

repo:huggingface/optimum-intel ltx-video path:/^tests\/openvino\//

done. Please review.

@likholat

Copy link
Copy Markdown

@rkazants please take a look

@rkazants

Copy link
Copy Markdown
Collaborator

@altnnatra, please take a look

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Comment thread tests/openvino/test_ltx_export_config.py Outdated
@Yash-Vijay29 Yash-Vijay29 requested a review from anatyrova April 30, 2026 06:33
Comment thread optimum/exporters/openvino/convert.py Outdated
@Yash-Vijay29 Yash-Vijay29 marked this pull request as draft April 30, 2026 08:45
@Yash-Vijay29 Yash-Vijay29 marked this pull request as ready for review April 30, 2026 09:11
@Yash-Vijay29

Yash-Vijay29 commented Apr 30, 2026

Copy link
Copy Markdown
Author

@rkazants
Altered only Ltx pipeline in model patcher, tests seem to pass for the new test file i made,

Tried exporting the test model and it exports, let me know if any other changes.

Please rerun checks! thank you

@Yash-Vijay29 Yash-Vijay29 requested a review from rkazants April 30, 2026 09:14
@anatyrova

Copy link
Copy Markdown
Collaborator

Tests cannot be collected and export fails in environments with huggingface_hub>=1.0 due to ImportError: cannot import name 'HfFolder' in modeling_utils.py (pre-existing issue in main, not introduced by this PR). Could you pls confirm which version of huggingface_hub you tested with, @Yash-Vijay29 ?

@Yash-Vijay29

Copy link
Copy Markdown
Author

Tests cannot be collected and export fails in environments with huggingface_hub>=1.0 due to ImportError: cannot import name 'HfFolder' in modeling_utils.py (pre-existing issue in main, not introduced by this PR). Could you pls confirm which version of huggingface_hub you tested with, @Yash-Vijay29 ?

@anatyrova
0.36.2 was the version of huggingface_hub i got in my setup

@anatyrova

Copy link
Copy Markdown
Collaborator

The branch is based on an older commit of main where HfFolder was still used in modeling_utils.py. This has since been fixed in main. I think, rebase onto the current main will resolve the import error and unblock validation. Please try this.

@Yash-Vijay29 Yash-Vijay29 marked this pull request as draft April 30, 2026 19:11
@Yash-Vijay29 Yash-Vijay29 marked this pull request as ready for review April 30, 2026 19:44
@Yash-Vijay29

Copy link
Copy Markdown
Author

@anatyrova updated branch to latest commit, exporting model and "python -m pytest tests/openvino/test_ltx_export_config.py -v" passes

huggingface_hub used is still 0.36.2 (it auto downloaded that one)

Try running again! thank you!

@Yash-Vijay29 Yash-Vijay29 marked this pull request as draft May 1, 2026 14:06
@Yash-Vijay29

Yash-Vijay29 commented May 1, 2026

Copy link
Copy Markdown
Author

@anatyrova what version of diffusers is CI using?
its unable to process the tiny-random-ltx-video-0.9.1 's
"timestep_scale_multiplier", the one I used for testing was diffusers 0.37.1
and the tests that failed on the CI have passed on my VM

I think the diffusers on the CI is a bit old? and doesnt have the "timestep_scale_multiplier"
in it

@Yash-Vijay29 Yash-Vijay29 marked this pull request as ready for review May 1, 2026 14:16
@anatyrova

Copy link
Copy Markdown
Collaborator

i reviewed the pr for the case if it creates any regression for the prev LTX-video that we already have (m_id Lightricks/LTX-Video)
all in all, pr 1652 does not create a regression for the existing LTX.

  1. i compared first
    GT — HF PyTorch on main branch
    Target — OV export on pr-1652 branch
  2. then i compared
    GT — HF PyTorch on main
    Target — OV export on main

similarity results (wwb) were almost identical, both with 0.838127 (main) and 0.83812696 (pr) similarity comp. to OG model. @rkazants

Comment thread tests/openvino/utils_tests.py Outdated
"sana": "optimum-intel-internal-testing/tiny-random-sana",
"sana-sprint": "optimum-intel-internal-testing/tiny-random-sana-sprint",
"ltx-video": "optimum-intel-internal-testing/tiny-random-ltx-video",
"ltx-video-0.9.1": "creeper-hat/tiny-random-ltx-video-0.9.1",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anatyrova, please help to upload this tiny model into optimum-intel-internal-testing

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added: optimum-intel-internal-testing/tiny-random-ltx-video-0.9.1

Comment thread tests/openvino/test_ltx_export_config.py Outdated
Comment thread tests/openvino/utils_tests.py Outdated
self._model.pos_embed.forward = self._model.pos_embed._orig_forward


def _ltx_vae_decoder_forward(model, latent_sample, timestep=None):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yash-Vijay29, why do we need this new model patching? Why does existing patching not work?
Please try without this patch. If not possible, please leave a comment why do we need it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current VAE decoder export is not enough for LTX 0.9.1-style VAEs because these models are timestep-conditioned. Diffusers calls the decoder as vae.decode(latents, timestep) / decode(z, temb=...) only when vae.config.timestep_conditioning is true. If we export it through the normal VAE decoder path, the OpenVINO graph only has latent_sample, so decode_timestep cannot be passed at runtime.

I tried running it earlier and it produced some incorrect dummy shape for the timestep and failed to export the model for the said weights.


return [value] * effective_batch_size

def __call__(self, *args, **kwargs):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this call method and why existing one does not work?
By this new call method, can we affect existing LTX inference?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this call method and why existing one does not work? By this new call method, can we affect existing LTX inference?

While testing the num_videos_per_prompt > 1 was an issue for the timestep enabled models

Diffusers LTX currently prepares latents with effective batch:
batch_size * num_videos_per_prompt

but later, for VAE timestep conditioning, it expands decode_timestep only to:
batch_size

in one of the tests it produced a result of
batch_size = 3
num_videos_per_prompt = 3
latents batch = 9
decode_noise_scale / timestep batch = 3

giving a 3 vs 9 tensor error.

I added it because i had run the currently deleted test suite on the new ltx_video-0.9.1 and it failed this test as a result.

I will narrow it down so it only applies on num_videos_per_prompt > 1 and timestep_conditioning = True
as extra precaution so it doesnt affect existing LTX inference (existing LTX inference only exists for models where timestep_conditioning is False).

prompt_embeds = kwargs.get("prompt_embeds")
num_videos_per_prompt = kwargs.get("num_videos_per_prompt", 1) or 1

if num_videos_per_prompt == 1 or not getattr(self.vae.config, "timestep_conditioning", False):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkazants added a line so it only works for timestep_conditioning = true models with num_videos_per_prompt > 1 where there was an issue. if you feel something is off do let me know!

@likholat

Copy link
Copy Markdown

@rkazants Are we ready to merge this PR? Could you please add the PR to the merge queue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants